﻿using DreamCMS.BLL;
using DreamCMS.BLL.Common;
using DreamCMS.Entity;
using DreamCMS.Entity.Common;
using DreamCMS.WebCore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DreamCMS.Web.Admin
{
    public partial class Manage : AdminPageBase
    {
        private bool IsOpenSite = true;
        public Manage()
        {
            if (SiteSettingManager.GetSiteSettingInfo().TheSiteStatus == 0)
            {
                IsOpenSite = false;
            }
            else
            {
                IsOpenSite = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ltrUserName.Text = "欢迎您" + LoginHelper.CurrentUserName;
            if (IsOpenSite)
            {
                closeSite.Text = "<span>关闭网站</span>";
            }
            else
            {
                closeSite.Text = "<span>开启站点</span>";
            }
        }
        /// <summary>
        /// 登出操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lkbLogout_Click(object sender, EventArgs e)
        {
            LoginHelper.RemoveUserCookie();
            Response.Redirect("~/admin/default.aspx");
        }
        /// <summary>
        /// 关闭站点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void closeSite_Click(object sender, EventArgs e)
        {
            if (IsOpenSite)
            {
                SiteSettingManager.GetSiteSettingInfo().TheSiteStatus = 0;
                SiteSettingManager.UpdateSettingInfo();
                closeSite.Text = "<span>开启站点</span>";
            }
            else
            {
                SiteSettingManager.GetSiteSettingInfo().TheSiteStatus = SiteStatus.OpenIt;
                SiteSettingManager.UpdateSettingInfo();
                closeSite.Text = "<span>关闭站点</span>";
            }
        }
    }
}